package entityMapping.demo1;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

public class Main {
    public static void main(String[] args) {
        ApplicationContext context = new FileSystemXmlApplicationContext("conf/beans.xml");
        SessionFactory factory = context.getBean(SessionFactory.class);

        CompositeKeyEntity2 entity = new CompositeKeyEntity2();
        entity.setKey1("S12");
        entity.setKey2("S2");
        entity.setValue("Value");

        System.out.println(entity);

        Session session = factory.openSession();
        Transaction tx = session.beginTransaction();
        session.saveOrUpdate(entity);
        tx.commit();
    }
}
